class Solution {
    vector<vector<int>> ret;
    vector<int> path;
public:
    vector<vector<int>> subsets(vector<int>& nums) {
        // 时间O(N * 2^N) 空间O(N)
        dfs(nums, 0);
        return ret;
    }
 
    void dfs(vector<int> nums, int pos)
    {
        if(pos == nums.size())
        {
            ret.push_back(path);
            return;
        }
        path.push_back(nums[pos]); // 选
        dfs(nums, pos + 1);
        path.pop_back(); // 恢复现场
 
        dfs(nums, pos + 1); // 不选
    }
};